const { defineConfig } = require('@vue/cli-service')
const { VantResolver } = require('unplugin-vue-components/resolvers')
const ComponentsPlugin = require('unplugin-vue-components/webpack')
const path = require('path')
function resolve(dir) {
  return path.join(__dirname, './', dir)
}

module.exports = defineConfig({
  transpileDependencies: true,
  productionSourceMap: false,
  lintOnSave: false,
  outputDir: `dist`,
  publicPath: process.env.VUE_APP_BASE_ROUTER,

  configureWebpack: {
    plugins: [
      ComponentsPlugin({
        resolvers: [VantResolver()],
        }),
    ],
    resolve: {
      alias: {
        '@': path.resolve(__dirname, './src'),
      },
    },
  },
  css: {
    loaderOptions: {
      less: {
        sourceMap: true
      }
    }
  },
  devServer: {
    port: '8090',
    // https: true,
    client: {
      overlay: false
    },
    proxy: {
      '^/api': {
        target: process.env.VUE_APP_BASE_URL,
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/api': '/api'
        }
      },
    },
  },
})
